package com.spring.controller.utils;


import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Configuration
public class interceptor implements HandlerInterceptor {
    // 实现HandlerInterceptor接口
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        // 从请求中获取token参数
        String token = request.getParameter("token");
        // 判断token是否有效
        if (!JwtUtil.checkJwt(token)){
            // 如果无效，返回true
            return true;
        }
        // 如果有效，返回false
        return false;
    }
}
